﻿@using BootstrapBlazor.Components
@using TrackSystem.Entities.Dtos.Slave
@using TrackSystem.Entities.Extensions
@using TrackSystem.Entities.Models


<div class="table-responsive">
    <table class="table custom-table">
        <thead>
        <tr>
            <th scope="col">
                <i class="fas fa-hashtag me-1"></i>
                序号
            </th>
            <th scope="col">
                <i class="fas fa-tag me-2"></i>
                参数名称
            </th>
            <th scope="col">
                <i class="fas fa-tag me-4"></i>
                实际值
            </th>
        </tr>
        </thead>

        <tbody>
        <tr>
            <td><span class="badge bg-primary">1</span></td>
            <td>端口名称</td>
            <td>@Slave.Name</td>
        </tr>
        <tr>
            <td><span class="badge bg-primary">2</span></td>
            <td>端口描述</td>
            <td>@Slave.Description</td>
        </tr>
        <tr>
            <td><span class="badge bg-primary">3</span></td>
            <td>协议类型</td>
            <td>@Slave.Protocol.ToString()</td>
        </tr>
        <tr>
            <td><span class="badge bg-success">4</span></td>
            <td>端口类型</td>
            <td>@Slave.PortCategory.ToString()</td>
        </tr>
        @if (Slave.PortCategory != PortCategory.SRIAL)
        {
            <tr>
                <td><span class="badge bg-info">5</span></td>
                <td>本机地址</td>
                <td>@Slave.LocalIP : @Slave.LocalPort</td>
            </tr>
            @if (Slave.PortCategory == PortCategory.UDP)
            {
                <tr>
                    <td><span class="badge bg-info">5</span></td>
                    <td>远程地址</td>
                    <td>@Slave.RemoteIP : @Slave.RemotePort</td>
                </tr>
            }
        }
        else
        {
            <tr>
                <td><span class="badge bg-info">5</span></td>
                    <td>串口参数</td>
                    <td>@Slave.Comx  @Slave.BaudRate bps @Slave.SerialParams</td>
            </tr>
        }

        <tr>
            <td><span class="badge bg-dark">6</span></td>
            <td>只读存储器地址表</td>
            <td>
                    <Textarea PlaceHolder="请输入只读存储器列表..." rows="4" @bind-Value="@Slave.RoList" readonly="true" />
                </td>
        </tr>

        @if (Slave.Protocol != SlaveProtocol.USERDEFINED)
        {
            <tr>
                <td><span class="badge bg-secondary">7</span></td>
                <td>读写存储器地址表</td>
                <td>
                        <Textarea PlaceHolder="请输入读写存储器列表..." rows="4" @bind-Value="@Slave.RwList" readonly="true" />
                </td>
            </tr>
            <tr>
                <td><span class="badge bg-danger">8</span></td>
                <td>站地址</td>
                <td>@Slave.Station</td>
            </tr>
        }
        else
        {
            <tr>
                <td><span class="badge bg-primary">8</span></td>
                <td>协议定义</td>
                <td>@Slave.ProtocolDefine</td>
            </tr>
            <tr>
                <td><span class="badge bg-success">9</span></td>
                <td>循环周期</td>
                <td>@Slave.Cycle</td>
            </tr>
        }
        </tbody>
    </table>
</div>

@code {
    [Parameter]
    public SlaveDto Slave { get; set; }
}
